package com.Blog.www.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/text1")
public class Text extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");

        PrintWriter pw = resp.getWriter();


        pw.print("<script language='javascript'>alert('恭喜您注册成功,您的账号为:" + "');" +
                "window.location.href='/Blog/login.html';</script>");
        /*//获取输出流'
        pw.write("<h1>恭喜你注册成功</h1>");
        pw.write("<h2>您的账号为:"+"</h2>");
        pw.write("<h2>请牢记</h2>");
        pw.write("<h2>页面将于5s后跳转</h2>");

        try {
            Thread.sleep(5000);
            //暂停几秒让用户可以看下数据
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        resp.sendRedirect("/Blog/login.html");*/
    }
}
